package com.chensf.studydemo.jetpack.viewmodel

import android.app.Application
import android.os.Bundle
import android.widget.TextView
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import com.chensf.studydemo.R

class ViewModelActivity1 : AppCompatActivity() {
    val viewModel1: ViewModel1 by viewModels()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        foo {
            13
        }
        val view = findViewById<TextView>(R.id.appbar).apply {
            text
        }

    }

    private fun foo(block: (() -> Int)? = null) {
        val promise = block ?: {
            10
        }

        println(promise())
    }

    private fun get(block: () -> Application) {

    }

    private fun test(): Application {
        return application
    }

}